﻿using DevExpress.XtraTreeList.Nodes;
using DevExpress.XtraTreeList;
using System;
using System.Collections.Generic;

namespace DevExpress.TreeList
{
    public partial class FormBinding : DevExpress.XtraEditors.XtraForm
    {
        public FormBinding()
        {
            InitializeComponent();
        }

        private void OnFormLoad(object sender, EventArgs e)
        {
            this.InitBindingTreeList();
            this.InitNodeTreeList();

        }

        private void InitBindingTreeList() 
        {
            var data = new List<TreeNodeModel>
            {
                new TreeNodeModel { Id = 1, Name = "根节点1", ParentId = null},
                new TreeNodeModel { Id = 2, Name = "子节点1.1", ParentId = 1 },
                new TreeNodeModel { Id = 3, Name = "子节点1.2", ParentId = 1 },
                new TreeNodeModel { Id = 4, Name = "子节点1.2.1", ParentId = 3 }
            };

            this.tlBinding.DataSource = data;
            this.tlBinding.KeyFieldName = "Id";
            this.tlBinding.ParentFieldName = "ParentId";
        }
        private void InitNodeTreeList() 
        {

        }


    }


}
